home *** CD-ROM | disk | FTP | other *** search
/ PD ROM 1 / PD ROM Volume I - Macintosh Software from BMUG (1988).iso / Programming / Programming Tools / Lightspeed Source Code / mmstr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1986-07-12  |  1.3 KB  |  88 lines  |  [TEXT/KAHL]

  1.  
  2.  
  3. /****************************************
  4. *                                        *
  5. *                                        *
  6. *      custom string library            *
  7. *              7/10/86                    *
  8. *               MMSTR.C                    *
  9. *                                        *
  10. *             LIGHTSPEED                    *
  11. *                                        *
  12. *        John Pence, Macman, Inc.        *
  13. *                                        *
  14. ****************************************/
  15.  
  16. /* 
  17.     in this file:
  18.     
  19.     char *strnac(str1,str2,num)
  20.         char *str1,str2;
  21.         int num;
  22.         
  23.     char *strtac(str1,str2)
  24.         char *str1,str2;
  25.         
  26. */
  27. extern int strlen();
  28.  
  29. char *strtac(s1,s2)
  30.     register char *s1,*s2;
  31.     {
  32.         char *result = s1;
  33.         register int n = strlen(s2);
  34.     
  35.         
  36.         while(*s1++);
  37.             
  38.         
  39.         while(--s1 >= result)
  40.             *(s1+n)=*s1;    /* move string1 over */
  41.         
  42.         
  43.         s1++;                /* point s1 back to start of string1 */
  44.         while(*s2)            /* move string2 into beginning of string1 */
  45.             *(s1++) = *(s2++);
  46.         
  47.         
  48.         return result;
  49.     } /* strtac */
  50.  
  51.  
  52.         
  53.  
  54. char *strntac(s1,s2,num)
  55.     register char *s1,*s2;
  56.     register int num;
  57.     {
  58.         register int i;
  59.         char *result = s1;
  60.         char *string2 = s2;
  61.         register int len2 = 0;
  62.         
  63.         if(num > (len2=strlen(s2) ) ) num = len2;    
  64.             
  65.         while(*s1++);         /* advance to end */
  66.         
  67.         while(--s1 >= result)
  68.             *(s1+num)=*s1;    /* move string1 over */
  69.         s1++ ;                /* point s1 back to start of string1 */
  70.         
  71.         for(i=0;i<num; i++)  /* move string2 into beginning of string1 */
  72.             s1[i] = s2[i];
  73.         
  74.         return result;
  75.     } /* strntac */    
  76.     
  77.  
  78.             
  79.         
  80.         
  81.     
  82.     
  83.     
  84.     
  85.     
  86.     
  87.  
  88.